<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>马思特奥赛培训学校网络管理系统</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport'/>

    <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/element-ui.css}">
    <style>
        td {
            text-align: center
        }
    </style>
</head>
<body>
<div class="wrapper" id="app">
    <div th:replace="student/public-student-index :: header"></div>
    <div th:replace="student/public-student-index :: left"></div>
    <div class="main-panel">
        <div class="content">
            <div class="row">
                <div class="col-md-2"></div>
                <div class="col-md-8">
                    <span style="text-align:center;display:block;font-size:25px;">修改信息</span>
                    <form action="#" id="modifyinfo">
                        <strong>班&nbsp;&nbsp;&nbsp;&nbsp;级:&nbsp;&nbsp;&nbsp;&nbsp;</strong>
                        <input type="text" 
                               class="form-control"
                               th:value="${tclass.className}"
                               name="className" readonly="readonly"><br/>
                        <strong>姓&nbsp;&nbsp;&nbsp;&nbsp;名:&nbsp;&nbsp;&nbsp;&nbsp;</strong>
                        <input type="text"
                               class="form-control"
                               th:value="${session.student.name}"
                               name="name" ><br/>
                        <strong>学&nbsp;&nbsp;&nbsp;&nbsp;号:&nbsp;&nbsp;&nbsp;&nbsp;</strong>
                        <input type="text"
                               class="form-control"
                               th:value="${session.student.stunum}"
                               name="stunum"><br/>

                        <strong>性&nbsp;&nbsp;&nbsp;&nbsp;别:&nbsp;&nbsp;&nbsp;&nbsp;</strong>
                        <select class="form-control" id="genderSelect" name="gender">
                            <option th:selected="${session.student.gender} eq '男' " value="男">男</option>
                            <option th:selected="${session.student.gender} eq '女' " value="女">女</option>
                        </select></br>
                        <strong>教学编号(登入号):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </strong>
                        <input type="text" disabled="disabled"
                               class="form-control"
                               th:value="${session.student.username}"
                               name="idnumber" readonly="readonly"><br/>
                        <button type="button" style="float:right;" class="btn btn-primary" @click="success">
                            确认修改
                        </button>
                    </form>
                </div>
                <div class="col-md-2"></div>
            </div>
        </div>
    </div>

</div>


</body>
<script type="text/javascript" th:src="@{/webjars/jquery/1.9.1/jquery.js}"></script>
<script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/js/Vue.js}"></script>
<script type="text/javascript" th:src="@{/js/element-ui.js}"></script>
<!--<script type="text/javascript" th:src="@{/asserts/js/ready.min.js}"></script>-->
<script th:inline="javascript">

    var basePath= /*[[${#httpServletRequest.getContextPath()}]]*/'ContextPath' ;

    var app = new Vue({
        el: "#app",
        data(){
            return{
                modifyFlag:/*[[${session.modifyFlag}]]*/'ContextPath'
            }
        },
        methods: {

            success:function () {
                $.ajax({
                    //几个参数需要注意一下
                    type: "PUT",//方法类型
                    //dataType: "json",//预期服务器返回的数据类型
                    url: basePath+'/student/modifyinfodao',//url
                    data: $('#modifyinfo').serialize(),
                    success: function (data) {
                        console.log(data);
                        if (data == 200) {
                            app.successpopup();
                            window.location.reload();
                        }
                        if (data == 201) {
                            app.errorpopup();
                        }

                    }
                })
            },
            successpopup(){
                this.$notify({
                    title: '成功',
                    message: '修改成功',
                    type: 'success'
                });
            },
            errorpopup(){
                this.$notify.error({
                    title: '错误',
                    message: '修改失败'
                });
            }
        },
        mounted(){
            if(this.modifyFlag == 1){

                this.successpopup()
            }
        }
    });





</script>
</html>